|
|
|
|
|
|
|
Figure 17.3
A sphere with Phong shading. |
|
|
|
|
|
|
|
|
Some of these effects are very difficult to implement when one uses the methods described in previous chapters. |
|
|
|
|
|
|
|
|
Before continuing, be aware that ray tracing relies on some fairly involved mathematics. Calculating how light refracts when it passes through a transparent object or finding the intersection between a ray and a cylinder is complicated. |
|
|
|
|
|
|
|
|
If you find you are overwhelmed by the mass of equations, skip them. The basic ray-tracing concepts are fairly intuitive, and you should be able to understand them even if you skip some of the details. Once you understand the basics, you will be able to modify the example programs to produce new arrangements of objects even if you have not memorized every last equation. |
|
|
|
|
|
|
|
|
The programs described in this chapter also include a lot of codetoo much code to print all of it here. To keep this chapter down to a manageable size, much detail is omitted. Only the code needed to illustrate important concepts is printed here. You can find the complete source code on the CD-ROM. |
|
|
|
|
|
|
|
|
The Z-Order and Depth-Sort hidden surface removal algorithms draw surfaces in order, drawing those furthest from the center of projection first. Surfaces that are drawn later cover up any previously drawn surfaces if necessary. |
|
|
|
|
|